/* GUI CONVERTED from reoprp23.p (converter v1.76) Fri Aug 24 23:38:07 2001 */
/* reoprp23.p - REJECT REPORT FROM OPERATIONS                                 */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.6.1.4 $                                                       */
/*V8:ConvertMode=FullGUIReport                                                */
/* REVISION: 1.0      LAST MODIFIED: 02/09/87   BY: EMB *A9*                  */
/* REVISION: 4.0      LAST MODIFIED: 02/24/88   BY: WUG *A175*                */
/* REVISION: 4.0      LAST MODIFIED: 03/27/89   BY: emb                       */
/* REVISION: 7.3      LAST MODIFIED: 05/17/93   BY: pma *GB05*                */
/* REVISION: 7.3      LAST MODIFIED: 08/30/94   BY: pxd *GL84*                */
/* REVISION: 8.6      LAST MODIFIED: 10/14/97   BY: bvm *K0ZD*                */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.6.1.3     BY: Hualin Zhong       DATE: 05/30/01   ECO: *N0YY*  */
/* $Revision: 1.6.1.4 $    BY: Manisha Sawant     DATE: 08/20/01   ECO: *P01N*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE          */

/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE reoprp23_p_2 "Units Started"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp23_p_3 "Units Rejected"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp23_p_6 "Reject %"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

define variable part like pt_part.
define variable part1 like pt_part.
define variable ptgroup like pt_group.
define variable group1 like pt_group.
define variable prod like pt_prod_line.
define variable prod1 like pt_prod_line.
define variable type like pt_part_type.
define variable type1 like pt_part_type.
define variable opdate like op_date.
define variable opdate1 like op_date.
define variable desc1 like pt_desc1.
define variable ytd_prod as decimal format "->>>,>>>,>>9"
   label {&reoprp23_p_2}.
define variable ytd_scrap as decimal format "->>>,>>>,>>9"
   label {&reoprp23_p_3}.
define variable ytd_pcnt as decimal format "->>9.99"
   label {&reoprp23_p_6}.
define variable name like ad_name.
define variable scrap_desc like rsn_desc.
define variable qty_scrap like ytd_scrap.

opdate = date(1,1,year (today)).


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
part           colon 15 part1          label {t001.i} colon 49
   prod           colon 15 prod1          label {t001.i} colon 49
   type           colon 15 type1          label {t001.i} colon 49
   ptgroup        colon 15 group1         label {t001.i} colon 49
   opdate         colon 15 opdate1        label {t001.i} colon 49 skip
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

{wbrp01.i}


/*GUI*/ {mfguirpa.i true "printer" 132 " " " " " "  }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:

   if group1 = hi_char then group1 = "".
   if opdate = low_date then opdate = ?.
   if opdate1 = hi_date then opdate1 = ?.
   if part1 = hi_char then part1 = "".
   if type1 = hi_char then type1 = "".
   if prod1 = hi_char then prod1 = "".

   if c-application-mode <> 'web' then
   
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


   {wbrp06.i &command = update
             &fields = "  part part1 prod prod1 type type1
                        ptgroup group1 opdate opdate1"
             &frm = "a"}

   if (c-application-mode <> 'web') or
      (c-application-mode = 'web' and
      (c-web-request begins 'data')) then do:

      bcdparm = "".
      {mfquoter.i part   }
      {mfquoter.i part1  }
      {mfquoter.i prod   }
      {mfquoter.i prod1  }
      {mfquoter.i type   }
      {mfquoter.i type1  }
      {mfquoter.i ptgroup}
      {mfquoter.i group1 }
      {mfquoter.i opdate }
      {mfquoter.i opdate1}

      if group1 = "" then group1 = hi_char.
      if opdate = ? then opdate = low_date.
      if opdate1 = ? then opdate1 = hi_date.
      if part1 = "" then part1 = hi_char.
      if prod1 = "" then prod1 = hi_char.
      if type1 = "" then type1 = hi_char.

   end.

   /* OUTPUT DESTINATION SELECTION */
   
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i "printer" 132 " " " " " " " " }
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:



   {mfphead.i}

   for each pt_mstr
   where pt_part >= part and pt_part <= part1
         and pt_prod_line >= prod and pt_prod_line <= prod1
         and pt_part_type >= type and pt_part_type <= type1
         and pt_group >= ptgroup and pt_group <= group1
         use-index pt_part
         no-lock by pt_part with frame b width 132 no-attr-space:

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame b:handle).

      assign
         qty_scrap = 0
         ytd_prod  = 0.

      if pt_routing = "" then
         find first ro_det where ro_routing = pt_part no-lock no-error.
      else
         find first ro_det where ro_routing = pt_routing no-lock no-error.

      if available ro_det then do:

         for each op_hist no-lock
            where op_part = pt_part
              and op_wo_op = ro_op
              and (op_date >= opdate and op_date <= opdate1)
            use-index op_part:

            ytd_prod = ytd_prod + op_qty_comp + op_qty_rjct.

         end.
      end.

      for each op_hist
      where op_part = pt_part
            and (op_date >= opdate and op_date <= opdate1)
            no-lock break by op_part by op_rsn_rjct with frame b:

         if first-of(op_part) then display pt_part pt_desc1 WITH STREAM-IO /*GUI*/ .

         if first-of(op_rsn_rjct) then do with frame b:
            scrap_desc = "".
            if op_type <> "SCRAP" then do:
               find rsn_ref
               where rsn_type = "reject"
                  and rsn_code = op_rsn_rjct no-lock no-error.
               if available rsn_ref then scrap_desc = rsn_desc.
               display op_rsn_rjct scrap_desc WITH STREAM-IO /*GUI*/ .
            end.
         end.

         if op_type = "SCRAP" then
            qty_scrap = qty_scrap + op_qty_rjct.
         else do:
            accumulate op_qty_rjct (total by op_rsn_rjct).
            accumulate op_qty_rjct (total by op_part).
         end.

         if last-of(op_rsn_rjct) then do with frame b:

            display
               ytd_prod @ ytd_prod
               (accum total by op_rsn_rjct op_qty_rjct) @ ytd_scrap WITH STREAM-IO /*GUI*/ .
            if ytd_prod <> 0 then
            if (accum total by op_rsn_rjct op_qty_rjct)
               / ytd_prod * 100 > -999 and
               (accum total by op_rsn_rjct op_qty_rjct)
               / ytd_prod * 100 < 1000 then
            display
               (accum total by op_rsn_rjct op_qty_rjct)
               / ytd_prod * 100
               @ ytd_pcnt WITH STREAM-IO /*GUI*/ .
            else do with frame b:
               if (accum total by op_rsn_rjct op_qty_rjct)
                  / ytd_prod > 0 then
                  display "> 999.99" @ ytd_pcnt WITH STREAM-IO /*GUI*/ .
               else display "<-999.99" @ ytd_pcnt WITH STREAM-IO /*GUI*/ .
            end.
            down 1.
         end.
         if last-of(op_part) then do with frame b:
            display
               fill("-",30) format "x(13)" @ ytd_prod
               fill("-",30) format "x(14)" @ ytd_scrap
               fill("-",30) @ ytd_pcnt WITH STREAM-IO /*GUI*/ .
            down 1.
            display
               getTermLabelRt("TOTAL",24) @ scrap_desc
               ytd_prod
               (accum total by op_part op_qty_rjct) @ ytd_scrap WITH STREAM-IO /*GUI*/ .
            if ytd_prod <> 0 then
               if (accum total by op_part op_qty_rjct)
                  / ytd_prod * 100 > -999 and
                  (accum total by op_part op_qty_rjct)
                  / ytd_prod * 100 < 1000 then
                  display (accum total by op_part op_qty_rjct)
                     / ytd_prod * 100 @ ytd_pcnt WITH STREAM-IO /*GUI*/ .
            else do with frame b:
               if (accum total by op_part op_qty_rjct) / ytd_prod > 0 then
                  display "> 999.99" @ ytd_pcnt WITH STREAM-IO /*GUI*/ .
               else display "<-999.99" @ ytd_pcnt WITH STREAM-IO /*GUI*/ .
            end.
            down 1.
            display
               getTermLabelRt("SCRAPPED",24) @ scrap_desc
               qty_scrap @ ytd_scrap WITH STREAM-IO /*GUI*/ .
            down 1.
            underline ytd_scrap.
            down 1.
            display
               getTermLabelRt("NET_REJECTS",24) @ scrap_desc
               (accum total by op_part op_qty_rjct) + qty_scrap @ ytd_scrap WITH STREAM-IO /*GUI*/ .
            down 1.
         end.
      end.

      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/

   end.

   /* REPORT TRAILER */
   
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


end.

{wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" part part1 prod prod1 type type1 ptgroup group1 opdate opdate1 "} /*Drive the Report*/
